package com.shangxia.spr.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shangxia.common.vo.ResultVO;
import com.shangxia.spr.Service.AttributeService;
import com.shangxia.spr.mapper.dao.Attribute;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhouya38158
 * @date 2021/11/19 14:04
 * @apiNote 属性控制器
 */
@Api
@RestController
@RequestMapping("/attribute")
public class AttributeController {

    @Autowired
    private AttributeService attributeService;

    @PutMapping("/")
    @ApiOperation(notes = "属性", value = "增加属性")
    public ResultVO<Attribute> saveOrUpdateAttribute(@RequestBody Attribute attribute) {
        attributeService.saveOrUpdate(attribute);
        return ResultVO.okResultVO(attribute);
    }

    @PostMapping("/list")
    @ApiOperation(notes = "属性", value = "查看属性")
    public ResultVO<Attribute> getAttribute(@RequestBody Attribute attribute) {
        return ResultVO.okResultVO(attributeService.list(new QueryWrapper<>(attribute)));
    }


}
